package com.future.lock.mall.view;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;

import com.yzh.modaldialog.dialog.impl.SelectorDialog;

import java.util.ArrayList;

/**
 * Created by yzh on 2017/9/17.
 */

public class ImageViewSelectorDialog extends SelectorDialog {
    public ImageViewSelectorDialog(@NonNull Context context) {
        super(context);
    }

    public ImageViewSelectorDialog(@NonNull Context context, int layoutResId) {
        super(context, layoutResId);
    }

    public ImageViewSelectorDialog(@NonNull Context context, int layoutResId, int theme) {
        super(context, layoutResId, theme);
    }

    @Override
    protected void searchButtons(View v, ArrayList<View> buttons) {
        if (v instanceof ViewGroup) {
            ViewGroup vg = (ViewGroup) v;

            for (int i = 0; i < vg.getChildCount(); ++i) {
                v = vg.getChildAt(i);
                if (v instanceof Button) {
                    buttons.add(v);
                }
                else if (v instanceof ImageButton) {
                    buttons.add(v);
                }
                else if (v instanceof ImageView) {
                    buttons.add(v);
                }
                else {
                    this.searchButtons(v, buttons);
                }
            }

        }
    }
}
